package com.its.equipment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.its.equipment.mapper.EmploymentMapper;
import com.its.equipment.pojo.Employment;
import com.its.equipment.service.EmploymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author lenovo
* @description 针对表【gym_employment】的数据库操作Service实现
* @createDate 2025-04-22 23:07:46
*/
@Service
public class EmploymentServiceImpl extends ServiceImpl<EmploymentMapper, Employment> implements EmploymentService {
    //依赖注入Mapper层属性
    @Autowired
    private EmploymentMapper employmentMapper;

    //新增设备
    @Override
    public int addEquipmentService(Employment employment) {
        return employmentMapper.insert(employment);
    }

    //删除设备
    @Override
    public int delEquipmentService(Integer equipmentId) {
        return employmentMapper.deleteById(equipmentId);
    }

    //更新设备信息
    @Override
    public int updateEquipmentService(Employment employment) {
        return employmentMapper.updateById(employment);
    }

    //根据设备Id查询设备信息
    @Override
    public Employment selectEquipmentById(Integer equipmentId) {
        return employmentMapper.selectById(equipmentId);
    }

    //根据设备名称查询设备
    @Override
    public Employment selectEquipment(String equipmentName) {
        QueryWrapper<Employment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("equipment_name",equipmentName);
        return employmentMapper.selectOne(queryWrapper);
    }

    //分页查询所有设备信息
    @Override
    public Page<Employment> getAllEquipment(Integer page, Integer size) {
        return employmentMapper.selectPage(new Page<>(page,size),null);
    }
}




